﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SQLExecute;
using System.Data;
using System.Web.UI.WebControls;
using AjaxControlToolkit;


/// <summary>
/// Summary description for disciplines
/// </summary>
public class MajorSubject
{
	public MajorSubject()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public MajorSubject(string strMajorSubjectName)
    {
        _majorsubjectname = strMajorSubjectName;
    }
    private int _majorid;
    public int MajorID
    {
        set { _majorid = value; }
        get { return _majorid; }
    }
    private string _majorsubjectname;
    private string _city_id;
    private string _school_id;
    DataSet ds;
    public string MajorSubjectName
    {
        set {_majorsubjectname=value;}
        get {return _majorsubjectname;}
    }

    public string CityID
    {
        set { _city_id = value; }
        get { return _city_id; }
    }
    public string SchoolID
    {
        set { _school_id = value; }
        get { return _school_id; }
    }

    public void Insert_Major_Subject()
    {
        SqlHelper.ExecuteNonQuery(Common.strConnect, "Insert_Major_Subject", new object[] {_majorsubjectname});
    }
   
    public void Init_Major_Subject(ComboBox major1, DropDownList major2, DropDownList major3, DropDownList major4)
    {
        string sql = "select distinct majorsubject_name from tbl_majorsubject order by majorsubject_name";
        ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, sql);
        major1.DataSource = ds.Tables[0];
        
        major1.DataTextField= "majorsubject_name";
        //major1.DataValueField = "id";
        major1.DataBind();
        

    }
    public void Init_Major_Subject2(ComboBox major1, ComboBox major2, ComboBox major3, ComboBox major4)
    {
        string sql = "select * from tbl_majorsubject2  order by majorsubject_name";
        ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, sql);
        major1.DataSource = ds.Tables[0];
        
        major1.DataTextField = "majorsubject_name";        
        major1.DataValueField = "id";
        major1.DataBind();
        major1.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major1.SelectedIndex = 0;

        
        major2.DataSource = ds.Tables[0];
        major2.DataTextField = "majorsubject_name";
        major2.DataValueField = "id";
        major2.DataBind();
        major2.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major2.SelectedIndex = 0;


        major3.DataSource = ds.Tables[0];
        major3.DataTextField = "majorsubject_name";
        major3.DataValueField = "id";
        major3.DataBind();
        major3.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major3.SelectedIndex = 0;



        major4.DataSource = ds.Tables[0];
        major4.DataTextField = "majorsubject_name";
        major4.DataValueField = "id";
        major4.DataBind();
        major4.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major4.SelectedIndex = 0;
        

    }
    public void Init_Major_Subject3(ComboBox major1, ComboBox major2, ComboBox major3, ComboBox major4)
    {
        string sql = "select * from tbl_majorsubject2 order by majorsubject_name";
        ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, sql);
        major1.DataSource = ds.Tables[0];

        major1.DataTextField = "majorsubject_name";
        major1.DataValueField = "id";
        major1.DataBind();
        //major1.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major1.SelectedIndex = 0;


        major2.DataSource = ds.Tables[0];
        major2.DataTextField = "majorsubject_name";
        major2.DataValueField = "id";
        major2.DataBind();
        //major2.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major2.SelectedIndex = 0;


        major3.DataSource = ds.Tables[0];
        major3.DataTextField = "majorsubject_name";
        major3.DataValueField = "id";
        major3.DataBind();
        //major3.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major3.SelectedIndex = 0;



        major4.DataSource = ds.Tables[0];
        major4.DataTextField = "majorsubject_name";
        major4.DataValueField = "id";
        major4.DataBind();
        //major4.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        major4.SelectedIndex = 0;


    }
    public DataSet Get_List_MajorSubject(string city_id, string school_id)
    {
        ds = SqlHelper.ExecuteDataset(Common.strConnect, "Get_List_MajorSubject", new object[] { city_id, school_id });
        return ds;
    }
    public void Get_List_MajorSubject(string city_id,string school_id,DropDownList cb)
    {

        ds = SqlHelper.ExecuteDataset(Common.strConnect, "Get_List_MajorSubject", new object[] { city_id, school_id });
        cb.DataSource = ds;
        cb.DataValueField = "id";
        cb.DataTextField = "majorsubject_name";
        cb.DataBind();
        
    }
    public void Get_List_Major_Subject2(GridView gd)
    {
        string sql = "select * from tbl_majorsubject2 where active=1 order by majorsubject_name asc";
        ds=SqlHelper.ExecuteDataset(Common.strConnect,CommandType.Text,sql);
        if (ds.Tables[0].Rows.Count>0)
        {
            gd.DataSource=ds.Tables[0];
            gd.DataBind();
            gd.Columns[1].Visible = false;

        }

    }
    
    public void Get_All_Major(DropDownList cb)
    {
        string strSQL = "select * from tbl_majorsubject";
        ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, strSQL);
        cb.DataSource = ds;
        cb.DataValueField = "id";
        cb.DataTextField = "majorsubject_name";
        cb.DataBind();
        cb.Items.Insert(0, new ListItem("CHOOSE ONE", "CHOOSE ONE"));
        cb.SelectedIndex = 0;


    }
    public void Update_Major_Subject()
    { 
    //  string str='update 
        SqlHelper.ExecuteNonQuery(Common.strConnect, "Update_Major_Subject", new object[] { _majorid, _majorsubjectname });
    }

    public bool Major_Exist()
    {
        string sql = "select * from tbl_majorsubject2 where majorsubject_name=N'" + _majorsubjectname + "'";
        ds = SqlHelper.ExecuteDataset(Common.strConnect, CommandType.Text, sql);
        if (ds.Tables[0].Rows.Count > 0)
            return true;
        else return false;
    }

}
